package vcp.gui.panels.customerservice;

import java.awt.GridLayout;

import javax.swing.JButton;

import javax.swing.JScrollPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

import vcp.gui.components.VCPPanel;
import vcp.gui.components.VCPScrollTable;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTextPane;

/**
 * Resolve Complaints panel
 */
public class PnlResolveComplaints extends VCPPanel {
	
	private static final long serialVersionUID = 1L;
	private VCPScrollTable complaintsTable;
	private VCPPanel complaintPane;
	private JTextField txtComplaintTitle;
	private  JTextPane textDetails;
	private JTextField textCompensate;
	private JButton btnCompensation;
	private int compID;

	public int getCompID() {
		return compID;
	}

	public void setCompID(int compID) {
		this.compID = compID;
	}

	public PnlResolveComplaints() {
        super(new GridLayout(2,0));
        complaintsTable = getComplaintsTable();
        complaintPane = new VCPPanel();
        add(complaintsTable);
        add(complaintPane);
        
        JLabel lblTitle = new JLabel("Title");
        lblTitle.setBounds(12, 13, 56, 16);
        
        txtComplaintTitle = new JTextField();
        txtComplaintTitle.setEditable(false);
        txtComplaintTitle.setBounds(80, 10, 541, 22);
        txtComplaintTitle.setColumns(10);
        
        textDetails = new JTextPane();
        textDetails.setEditable(false);
        textDetails.setBounds(80, 45, 358, 92);
        
        
        JLabel lblDetails = new JLabel("Details");
        lblDetails.setBounds(12, 42, 56, 16);
        
        JScrollPane scrollPane = new JScrollPane(textDetails);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        scrollPane.setBounds(80, 45, 541, 92);
        complaintPane.setLayout(null);
        complaintPane.add(lblTitle);
        complaintPane.add(txtComplaintTitle);
        complaintPane.add(lblDetails);
        complaintPane.add(scrollPane);
        
        JLabel lblCompensationAmount = new JLabel("Compensation amount");
        lblCompensationAmount.setBounds(80, 150, 142, 47);
        complaintPane.add(lblCompensationAmount);
        
        textCompensate = new JTextField();
        textCompensate.setBounds(221, 162, 400, 22);
        complaintPane.add(textCompensate);
        textCompensate.setColumns(10);
        
        btnCompensation = new JButton("Compensate");
        btnCompensation.setBounds(495, 197, 126, 25);
        complaintPane.add(btnCompensation);
	}
	
	public JTextField getTextCompensate() {
		return textCompensate;
	}

	public void setTextCompensate(JTextField textCompensate) {
		this.textCompensate = textCompensate;
	}

	public JButton getBtnCompensation() {
		return btnCompensation;
	}

	public void setBtnCompensation(JButton btnCompensation) {
		this.btnCompensation = btnCompensation;
	}

	public JTextField getTxtComplaintTitle() {
		return txtComplaintTitle;
	}

	public void setTxtComplaintTitle(JTextField txtComplaintTitle) {
		this.txtComplaintTitle = txtComplaintTitle;
	}

	public JTextPane getTextDetails() {
		return textDetails;
	}

	public void setTextDetails(JTextPane textDetails) {
		this.textDetails = textDetails;
	}

	public VCPPanel getComplaintPane() {
		return complaintPane;
	}

	public void setComplaintPane(VCPPanel complaintPane) {
		this.complaintPane = complaintPane;
	}
	
	
	
	

	/**
	 * gets complaints table
	 * @return complaints table
	 */
	public VCPScrollTable getComplaintsTable() {
		if(complaintsTable==null){
			String header[] = {"id","Details","Customer ID", "Order ID", "Title", "Resolved"};
			DefaultTableModel dtm = new DefaultTableModel(null, header) {
	    		private static final long serialVersionUID = 1L;
	    		@Override
	            public Class<?> getColumnClass(int col) {
	                return getValueAt(0, col).getClass();
	            }
	    	
	            public boolean isCellEditable(int row, int column){  
	                if(column==5)
	                	return true;
	            	return false;  
	            }            
	           
	        };
			
	        complaintsTable = new VCPScrollTable(10,dtm);			
		     TableColumn column1 = complaintsTable.getTable().getColumnModel().getColumn(0);
		    column1.setMinWidth(0);
		    column1.setMaxWidth(0);
		    column1.setWidth(0);
		    column1.setPreferredWidth(0);
		    TableColumn column2 = complaintsTable.getTable().getColumnModel().getColumn(1);
		    column2.setMinWidth(0);
		    column2.setMaxWidth(0);
		    column2.setWidth(0);
		    column2.setPreferredWidth(0);
		   
		   

		}
		return complaintsTable;
	}
}
